/**
 *  配置文件工具类
 */
package com.song.ejf.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class ConfigUtil {
	final static Log log = LogFactory.getLog(ConfigUtil.class);
	private static Properties properties;
	static{
		InputStream is = ConfigUtil.class.getClassLoader().getResourceAsStream("config.properties");
		properties = new Properties();
		try {
			properties.load(is);
		} catch (IOException e) {
			log.error("配置文件config.properties加载失败!",e);
		}finally{
			try {
				if(is != null){
					is.close();
				}
			} catch (IOException e) {
				log.error("关闭流失败!",e);
			}
		}
	}
	/**
	 * 根据key返回值。
	 * @param key
	 * @return 如果没有相关值。则返回“”
	 */
	public static String getValue(String key){
		if(StringUtils.isBlank(key)){
			return null;
		}
		String temp = properties.getProperty(key);
		if(StringUtils.isBlank(temp) || "null".equals(temp)){
			return "";
		}
		return temp;
	}
}
